package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

public interface UserMapper {

    /**
     * 根据openid查询用户是否为新用户
     *
     * @param openid
     * @return
     */
    @Select("select * from user where openid = #{openid}")
    User selectByOpenid(String openid);

    /**
     * 向用户表添加用户
     *
     * @param user
     */
    @Insert("insert into user(openid, name, create_time) value (#{openid},#{name},#{createTime})")
    void addUser(User user);

    /**
     * 根据id查询用户信息
     *
     * @param userId
     * @return
     */
    @Select("select * from user where id = #{userId}")
    User SelectById(Long userId);

    /**
     * 根据条件查询用户数量
     * @param start
     * @param end
     * @return
     */
    Integer countByMap(LocalDateTime start, LocalDateTime end);
}
